package com.winning.gjhlht.bi.controller;

import java.util.HashMap;


import org.apache.log4j.Logger;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.impl.StdSchedulerFactory;

import com.winning.common.Constans;
import com.winning.core.job.factory.QuartzJobFactory;

/**
 * 类名称：BIDataUploadController
 * 类描述：总管指标数据上传任务，每月的1号11：33：00执行，不关心第几周
 * 创建人：liuwensheng
 * 创建时间：2017-1-3 下午1:55:09
 * 修改人：liuwensheng
 * 修改时间：2017-1-3 下午1:55:09
 * 修改备注：
 */
public class BIDataUploadController {
    private static Logger LOGGER = Logger.getLogger(Constans.LOG4J_PBS_LOGGER_ID);

    public void init() {
        //创建一个SchedulerFactory工厂实例
        SchedulerFactory schedulerFactory = new StdSchedulerFactory();

        String jobName = QuartzJobFactory.JOB_NAME_FIX + "BI_KPI_DATA_UPLOADE";

        String triggerName = QuartzJobFactory.TRIGGER_NAME_FIX + jobName;

        //设置quartz框架任务调度的时间表达式:"[秒] [分] [小时] [日] [月] [周] [年] 公式" --> "* * 14-18 * * ? * "
        String cronExpression = "00 00 02 1 * ? *";//"* * " + startTimeValue + "-" + endTimeValue + " * * ?";
        //每月的1号02：00：00执行，不关心第几周

        //任务框架之间传递参数只能通过Map共享
        HashMap<String, Object> jobDataMap = new HashMap<String, Object>();

        try {
            //通过SchedulerFactory构建Scheduler对象
            Scheduler scheduler = schedulerFactory.getScheduler();

            scheduler = QuartzJobFactory.createJob(jobName, triggerName, scheduler, com.winning.gjhlht.bi.job.BIDataUploadJober.class, cronExpression, jobDataMap, null);

            //任务调度器启动
            scheduler.start();
        } catch (SchedulerException e) {
            e.printStackTrace();
        }

    }

}
